//
//  XDBackMoneyTableViewCell.m
//  xindailianmeng
//
//  Created by 张东 on 2017/2/10.
//  Copyright © 2017年 xindailianmeng.cn. All rights reserved.
//

#import "XDBackMoneyTableViewCell.h"
#import "XDBackMoneyModel.h"
@interface XDBackMoneyTableViewCell ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *spacing;
@property (weak, nonatomic) IBOutlet UILabel *backNumbeLb;

@property (weak, nonatomic) IBOutlet UILabel *payTimeLb;

@property (weak, nonatomic) IBOutlet UILabel *payMoneyLb;

@property (weak, nonatomic) IBOutlet UILabel *payEarningsLb;

@property (weak, nonatomic) IBOutlet UILabel *statusLb;

@end

@implementation XDBackMoneyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self = [[NSBundle mainBundle] loadNibNamed:@"XDBackMoneyTableViewCell" owner:self options:nil].firstObject;
    }
    return self;
}

- (void)setModel:(XDBackMoneyModel *)model {
//    currentBackNumbe = 1;
//    payBackNumber = 1;
//    payEarnings = "0.7";
//    payMoney = 111;
//    payTime = "2017-02-17 14:41:19";
//    "payBackNumber":6,                int 总期数
//    "currentBackNumbe":1,              int 当前期数
//    "payTime":1486707447000,          String到期时间
//    "payMoney":200.00,                 double应还本金
//    "payEarnings":3.22,                  double 利息
//    "status": "已收款"                     String   还款状态
//    (已收款,待收款)
//    status = "\U5f85\U6536\U6b3e";
    self.backNumbeLb.text = [NSString stringWithFormat:@"%zd/%zd期", model.currentBackNumbe, model.payBackNumber];
    
    self.payTimeLb.text = [NSString stringWithFormat:@"到期时间: %@",model.payTime];
    
    self.payMoneyLb.text = [NSString stringWithFormat:@"%.2f元",model.payMoney];
    
    self.payEarningsLb.text = [NSString stringWithFormat:@"+%.2f", model.payEarnings];
    
    self.statusLb.text = model.status;
    
    if ([model.status isEqualToString:@"已收款"]) {
        self.payMoneyLb.textColor = kColorRGB(153,153,153);
        
        self.payEarningsLb.textColor = kColorRGB(153,153,153);
        
        self.statusLb.textColor = kColorRGB(153,153,153);

    } else {
        self.payMoneyLb.textColor = kColorRGB(51,51,51);
        
        self.payEarningsLb.textColor = kColorRGB(51,51,51);
        
        self.statusLb.textColor = kColorRGB(187,147,115);
    }
    
}

- (void)layoutSubviews {
    self.spacing.constant = 110 * kscaleW;
}

@end
